package cn.zd.demo1.broadcast;

import static cn.zd.demo1.broadcast.MyBroadCastConstant.ACTION;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;

public class MyBroadCastReceiver extends BroadcastReceiver {
    private Context context;

    public MyBroadCastReceiver(Context context) {
        this.context = context;
    }

    @Override
    public void onReceive(Context context, Intent intent) {
        if(intent != null && intent.getAction().equals(ACTION)) {
            Toast.makeText(context,"接收到广播"+intent.getStringExtra("data"),Toast.LENGTH_SHORT).show();
        }
    }
}
